<template>
  <span class="operation">
    <el-button type="text" size="mini" @click.stop="select" v-if="data.isDir && unShowUploadBtn && !unShowMroeInfo">选择路径</el-button>
    <el-button type="text" size="mini" @click.stop="append" v-if="data.isDir && !unShowMroeInfo">新建子目录</el-button>
    <el-button type="text" size="mini" :disabled="true" v-if="data.isDir && !unShowUploadBtn && !unShowMroeInfo" @click.stop>
      <upload :showFileList="false" :isStuShow="isStuShow" :baseFileUrl="baseFileUrl + data.fileUrl" @fileDataUploaded="fileDataUploaded" :uploadedFileList="fileList" :currNo="currNo">
        <template #default>
          <el-button type="text" size="mini">上传</el-button>
        </template>
      </upload>
    </el-button>
    <el-button type="text" size="mini" @click.stop="handleSetHomePage"  v-if="isFile && data.type && data.fileUrl.indexOf('.html') !== -1 && !unShowMroeInfo">设为主页</el-button>
    <el-button type="text" size="mini" @click.stop="handleDecompression"  v-if="isFile && isZipFile && !unDecompression && !unShowMroeInfo">解压到</el-button>
    <el-button type="text" size="mini" @click.stop="handleDecompression"  v-if="isFile && isZipFile && unShowMroeInfo && (!data.subFiles || !data.subFiles.length) && !isArchive">解压</el-button>
    <el-button type="text" size="mini" @click.stop="handleNewDownLoad"  v-if="isFile && node.level === 1">下载</el-button>
    <!-- <el-button type="text" size="mini" @click.stop="handleDownLoad"  v-if="isFile">下载</el-button> -->
    <el-button type="text" size="mini" @click.stop="handleCopy" v-if="isFile && (!unShowMroeInfo || showCopyBtn)">复制链接</el-button>
    <!-- <el-button type="text" size="mini" @click.stop :disabled="true" v-if="!unShowMroeInfo">重命名</el-button> -->
    <el-button type="text" size="mini" @click.stop="remove" v-if="!unShowMroeInfo">删除</el-button>
    <el-button type="text" size="mini" @click.stop="remove" v-if="(isFile && isZipFile && unShowMroeInfo || node.level == 1) && !disabled && (!unShowGroupIcon && !unShowDeleteBtn)">删除</el-button>
  </span>
</template>

<script>
const upload = () => import("@/components/upload/index.vue")
export default {
  components: {
    upload
  },
  data() {
    return {}
  },
  props: {
    node:Object,
    data: Object,
    isStuShow: Boolean,
    baseFileUrl: String,
    unShowUploadBtn: Boolean,
    unDecompression: Boolean,
    unShowMroeInfo: Boolean,
    disabled: Boolean,
    unShowGroupIcon: Boolean, // 批阅状态
    unShowDeleteBtn: Boolean,
    fileList: Array,
    showCopyBtn: Boolean,
    currNo: Number,
    isArchive: Boolean, // 是否归档类型
  },
  computed: {
    isFile() {
      return !this.data.isDir && (!this.data.subFiles || !this.data.subFiles.length) || this.data.fileName.indexOf('.rar') !== -1 || this.data.fileName.indexOf('.zip') !== -1 || this.data.fileName.indexOf('.RAR') !== -1 || this.data.fileName.indexOf('.ZIP') !== -1 
    },
    isZipFile() {
      return this.data.fileName.indexOf('.rar') !== -1 || this.data.fileName.indexOf('.zip') !== -1 || this.data.fileName.indexOf('.RAR') !== -1 || this.data.fileName.indexOf('.ZIP') !== -1 
    }
  },
  methods: {
    append() {
      this.$emit("append")
    },
    fileDataUploaded(event) {
      this.$emit("fileDataUploaded", event)
    },
    handleSetHomePage() {
      this.$emit("handleSetHomePage")
    },
    handleCopy() {
      this.$emit("handleCopy")
    },
    remove() {
      this.$emit("remove")
    },
    handleDecompression() {
      this.$emit("decompression")
    },
    handleDownLoad() {
      this.$emit("downLoad")
    },
    handleNewDownLoad() {
      this.$emit("handleNewDownLoad")
    },
    select() {
      this.$emit("select")
    }
  }
}
</script>